<html>
<head><meta charset="utf-8"><title>a question about how passes work · t-compiler/wg-diagnostics · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/index.html">t-compiler/wg-diagnostics</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html">a question about how passes work</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="209002499"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209002499" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209002499">(Sep 03 2020 at 17:27)</a>:</h4>
<p>I was looking into <a href="https://github.com/rust-lang/rust/issues/75906">https://github.com/rust-lang/rust/issues/75906</a> and <a href="https://github.com/rust-lang/rust/issues/75907">https://github.com/rust-lang/rust/issues/75907</a><br>
looking into the how these errors work. My understanding is that the "bad" error happens during resolution, but the better one (realizing its a private field) happens during typeck, which happens AFTER resolution (well, i assume typeck now "queries" rustc_resolve). If this is true, then how can this error be improved?</p>



<a name="209005854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209005854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209005854">(Sep 03 2020 at 17:53)</a>:</h4>
<p><span class="user-mention" data-user-id="257428">@Gus Wynn</span> I would suggest recording additional information in <code>struct_constructors</code>: <a href="https://github.com/rust-lang/rust/blob/08deb863bdebfcbbb71c18acf903eca84f1df4e7/compiler/rustc_resolve/src/build_reduced_graph.rs#L815">https://github.com/rust-lang/rust/blob/08deb863bdebfcbbb71c18acf903eca84f1df4e7/compiler/rustc_resolve/src/build_reduced_graph.rs#L815</a></p>
<p>Specifically, I would suggest recording the fields from the constructor</p>



<a name="209005958"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209005958" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209005958">(Sep 03 2020 at 17:54)</a>:</h4>
<p>You can then modify the error-reporting code to determine the first inaccessible field: <a href="https://github.com/rust-lang/rust/blob/08deb863bdebfcbbb71c18acf903eca84f1df4e7/compiler/rustc_resolve/src/late/diagnostics.rs#L747-L756">https://github.com/rust-lang/rust/blob/08deb863bdebfcbbb71c18acf903eca84f1df4e7/compiler/rustc_resolve/src/late/diagnostics.rs#L747-L756</a></p>



<a name="209006059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209006059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209006059">(Sep 03 2020 at 17:55)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> ah interesting, thanks for the pointers, ill see if i can come up with anything</p>



<a name="209006302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209006302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209006302">(Sep 03 2020 at 17:57)</a>:</h4>
<p>Changing the error message will take more work, since it's constructed before that code is invoked</p>



<a name="209006328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209006328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209006328">(Sep 03 2020 at 17:57)</a>:</h4>
<p>feel free to ping me if you have any questions</p>



<a name="209006501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209006501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209006501">(Sep 03 2020 at 17:58)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> wait why will constructing the error message be difficult? is the error used in 747-756 the wrong span?</p>



<a name="209006610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209006610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209006610">(Sep 03 2020 at 17:59)</a>:</h4>
<p>The 'private fields' messages is added from <code>smart_resolve_context_dependent_help</code>, which is called with an existing <code>DiagnosticBuilder</code></p>



<a name="209006797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209006797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209006797">(Sep 03 2020 at 18:01)</a>:</h4>
<p>I think you'll need to modify <code>smart_resolve_report_errors</code> to construct a different <code>base_msg</code></p>



<a name="209007003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209007003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209007003">(Sep 03 2020 at 18:02)</a>:</h4>
<p>Ah okay, sounds like my plan is to 1. understand what i need to add to struct_constructors and 2. figure out how to build a new diagnostic</p>



<a name="209007063"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209007063" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209007063">(Sep 03 2020 at 18:03)</a>:</h4>
<p>Building an entire new diagnostic shouldn't be necessary - you'll just need to adjust the construction code</p>



<a name="209007111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209007111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209007111">(Sep 03 2020 at 18:03)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/08deb863bdebfcbbb71c18acf903eca84f1df4e7/compiler/rustc_resolve/src/late/diagnostics.rs#L123-L174">https://github.com/rust-lang/rust/blob/08deb863bdebfcbbb71c18acf903eca84f1df4e7/compiler/rustc_resolve/src/late/diagnostics.rs#L123-L174</a></p>



<a name="209007212"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209007212" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209007212">(Sep 03 2020 at 18:04)</a>:</h4>
<p>cc <span class="user-mention" data-user-id="119031">@Esteban Küber</span> - is there a good way of overwriting the main message of a <code>DiagnosticBuilder</code> after it's been constructed?</p>



<a name="209007310"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209007310" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209007310">(Sep 03 2020 at 18:05)</a>:</h4>
<p>it looks like the <code>message</code> field is public, but overwriting that seems a little hacky</p>



<a name="209008923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209008923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209008923">(Sep 03 2020 at 18:18)</a>:</h4>
<p>Omg, VariantData has .fields, which returns StructField's, which have the span's I need, i am continually impressed with rustc's ability to just put spans everywhere</p>



<a name="209009160"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209009160" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Esteban Küber <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209009160">(Sep 03 2020 at 18:20)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> a _good_ way, no. You can overwrite it and is hacky... I've done it a handful of times.</p>



<a name="209425527"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209425527" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209425527">(Sep 08 2020 at 18:28)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> I started looking at this again, I can't really figure out how to get the spans of <em>usages</em> of the fields (so the span of fy in <code>Bar(fy = ...</code></p>
<p>Looking into src/late/diagnostics.rs and src/late.rs, it seems like i actually need to pass the bindings here: <a href="https://github.com/rust-lang/rust/blob/5099914a16a215794ad243df0cc7a05d91d168e0/compiler/rustc_resolve/src/late.rs#L1543">https://github.com/rust-lang/rust/blob/5099914a16a215794ad243df0cc7a05d91d168e0/compiler/rustc_resolve/src/late.rs#L1543</a> down through the call stack to make it to smart_resolve_report_errors </p>
<p>does that make sense?<br>
also, this brings up 2 questions</p>
<ol>
<li>how do I know which of the bindings is private? i.e., how do I compare the Ident to the struct_constructors</li>
<li>what is different about Struct's that makes them not hit this error, whereas TupleStruct's do?</li>
</ol>



<a name="209426051"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209426051" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209426051">(Sep 08 2020 at 18:33)</a>:</h4>
<p>Separately, I might play around with this: <a href="https://github.com/rust-lang/rust/blob/08deb863bdebfcbbb71c18acf903eca84f1df4e7/compiler/rustc_privacy/src/lib.rs#L1105-L1150">https://github.com/rust-lang/rust/blob/08deb863bdebfcbbb71c18acf903eca84f1df4e7/compiler/rustc_privacy/src/lib.rs#L1105-L1150</a> and see if I can make this work for TupleStructs instead</p>



<a name="209435969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209435969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209435969">(Sep 08 2020 at 19:56)</a>:</h4>
<p><span class="user-mention" data-user-id="257428">@Gus Wynn</span> I think you'll want to pass down the second field of <code>PatKind::TupleStruct</code></p>



<a name="209436029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436029">(Sep 08 2020 at 19:57)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> yeah so in visit_pat if its a tuple struct i call...<code>self.visit_pat(the internal pat)</code> right?</p>



<a name="209436086"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436086" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436086">(Sep 08 2020 at 19:57)</a>:</h4>
<p>I don't think you need to add any new calls to <code>visit_pat</code></p>



<a name="209436167"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436167" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436167">(Sep 08 2020 at 19:58)</a>:</h4>
<p>I think you'll want to attach additional information to <code>PathSource</code></p>



<a name="209436205"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436205" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436205">(Sep 08 2020 at 19:58)</a>:</h4>
<p>which gets passed down to <code>smart_resolve_report_errors</code></p>



<a name="209436249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436249">(Sep 08 2020 at 19:59)</a>:</h4>
<p>What makes this somewhat tricky is the fact that you mentioned earlier - tuple structs and named structs are handled differently</p>



<a name="209436305"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436305" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436305">(Sep 08 2020 at 19:59)</a>:</h4>
<p>I'm not sure why, but it looks like the visibility of the internal 'constructor' for tuple structs is determined by looking at the fields</p>



<a name="209436382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436382">(Sep 08 2020 at 20:00)</a>:</h4>
<p>while for named structs, the constructor always has the same visibility as the struct itself, and field privacy is checked after resolution</p>



<a name="209436393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436393">(Sep 08 2020 at 20:00)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> oh im a bit confused, what makes it not possible to do this in the same place as structs (in rustc_privacy, in NamePrivacyVisitor)?</p>



<a name="209436417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436417">(Sep 08 2020 at 20:00)</a>:</h4>
<p><span class="user-mention silent" data-user-id="125294">Aaron Hill</span> <a href="#narrow/stream/147480-t-compiler.2Fwg-diagnostics/topic/a.20question.20about.20how.20passes.20work/near/209436305">said</a>:</p>
<blockquote>
<p>I'm not sure why, but it looks like the visibility of the internal 'constructor' for tuple structs is determined by looking at the fields</p>
</blockquote>
<p>hmm interesting, ill look into this</p>



<a name="209436460"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436460" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436460">(Sep 08 2020 at 20:00)</a>:</h4>
<p>ideally, you would be able to check it there</p>



<a name="209436493"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436493" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436493">(Sep 08 2020 at 20:01)</a>:</h4>
<p>I'm not sure why tuple structs have their constructor visibility handling done this way</p>



<a name="209436894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436894">(Sep 08 2020 at 20:04)</a>:</h4>
<p>It looks like this inconsistency actually results in user-observable differences: <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=e364e3402b9dae0bbc244907e9a38538">https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2018&amp;gist=e364e3402b9dae0bbc244907e9a38538</a></p>



<a name="209436961"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436961" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436961">(Sep 08 2020 at 20:04)</a>:</h4>
<p>You can pattern-match a named struct with private fields by using the wildcard pattern <code>..</code></p>



<a name="209436987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436987">(Sep 08 2020 at 20:04)</a>:</h4>
<p>since the constructor has the same visibility as the struct itself</p>



<a name="209436999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209436999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209436999">(Sep 08 2020 at 20:04)</a>:</h4>
<p>However, you cannot do this for tuple structs</p>



<a name="209437121"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437121" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437121">(Sep 08 2020 at 20:05)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> interesting...<br>
I may play around with NamePrivacyVisitor for a bit more, then try out the PathSource technique</p>



<a name="209437135"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437135" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437135">(Sep 08 2020 at 20:05)</a>:</h4>
<p>Changing this would require an FCP (if not an RFC), so I think we're stuck with the existing resolver logic for the time being</p>



<a name="209437245"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437245" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437245">(Sep 08 2020 at 20:06)</a>:</h4>
<p><span class="user-mention" data-user-id="257428">@Gus Wynn</span> I don't think <code>NamePrivacyVisitor</code> will ever get run on the relevant code</p>



<a name="209437302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437302">(Sep 08 2020 at 20:07)</a>:</h4>
<p>oh interesting...damn i have a lot to learn about rustc</p>



<a name="209437321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437321">(Sep 08 2020 at 20:07)</a>:</h4>
<p><code>NamePrivacyVisitor</code> gets run after type-checking (you can see this by noting how it uses <code>rustc_middle::ty::Ty</code>)</p>



<a name="209437369"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437369" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437369">(Sep 08 2020 at 20:07)</a>:</h4>
<p>However, the tuple struct error occurs during resolution, which means that type-checking will never run for the enclosing function</p>



<a name="209437382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437382">(Sep 08 2020 at 20:07)</a>:</h4>
<p>or if it does, it will not produce a useful result</p>



<a name="209437523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437523">(Sep 08 2020 at 20:08)</a>:</h4>
<p>Ahhh so that explains it, that this difference between TupleStructs and Structs is that the constructor is actually resolvable in rustc_resolve for Struct's for not TupleStructs, i had it backwards somehow</p>



<a name="209437547"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437547" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437547">(Sep 08 2020 at 20:09)</a>:</h4>
<p>yeah</p>



<a name="209437575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437575">(Sep 08 2020 at 20:09)</a>:</h4>
<p>I'm going to open an issue to get more details about why this inconsistency exists</p>



<a name="209437815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209437815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209437815">(Sep 08 2020 at 20:11)</a>:</h4>
<p>nice, will be interesting to know is there is a reason more than "this is how it was implemented"</p>



<a name="209438388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209438388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209438388">(Sep 08 2020 at 20:15)</a>:</h4>
<p>opened <a href="https://github.com/rust-lang/rust/issues/76494">https://github.com/rust-lang/rust/issues/76494</a></p>



<a name="209439266"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209439266" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Aaron Hill <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209439266">(Sep 08 2020 at 20:23)</a>:</h4>
<p><span class="user-mention" data-user-id="257428">@Gus Wynn</span> Supporting the full set of possibilities (e.g. <code>let TupleStruct(a, ..) = foo</code>) could be tricky. If you don't want to deal with that, I think it would be fine for your PR to only handle the case where all fields are named (e.g. <code>let foo = TupleStruct(a, b, c)</code> and <code>let TupleStruct(a, b, c) = foo</code>)</p>



<a name="209439605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209439605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209439605">(Sep 08 2020 at 20:25)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> yeah I figured, I am currently at "ok now match up the Vec&lt;P&lt;Pat&gt; with the fields and their resolved visibility</p>



<a name="209443893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209443893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209443893">(Sep 08 2020 at 21:02)</a>:</h4>
<p>oh jeez PathSource is Copy, i wanted a Vec of Idents for all the fields <span aria-label="frown" class="emoji emoji-1f641" role="img" title="frown">:frown:</span> may just go with the first non-pub one</p>



<a name="209451384"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209451384" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209451384">(Sep 08 2020 at 22:20)</a>:</h4>
<p>set_primary_message, replace_span_with, and .code all let sneak by with an easier adjustment to the diagnostic code!<br>
<a href="https://github.com/rust-lang/rust/pull/76499">https://github.com/rust-lang/rust/pull/76499</a></p>
<p>This, while hard for me while I get my bearings, has been a great way to get ramped up</p>



<a name="209576364"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/147480-t-compiler/wg-diagnostics/topic/a%20question%20about%20how%20passes%20work/near/209576364" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Gus Wynn <a href="https://rust-lang.github.io/zulip_archive/stream/147480-t-compiler/wg-diagnostics/topic/a.20question.20about.20how.20passes.20work.html#209576364">(Sep 09 2020 at 22:29)</a>:</h4>
<p><span class="user-mention" data-user-id="125294">@Aaron Hill</span> <span class="user-mention" data-user-id="119031">@Esteban Küber</span> no rush, but if you find time, do you mind looking at the way I setup the span_label in <a href="https://github.com/rust-lang/rust/pull/76499">https://github.com/rust-lang/rust/pull/76499</a> and seeing if there is a better way? Thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>